package context;

public final class Log
{ private static final String VERBOSE="VERBOSE";
  private static final String DEBUG="DEBUG";
  private static final String INFO="INFO";
  private static final String WARN="WARN";
  private static final String ERROR="ERROR";
//private static Boolean lock=new Boolean(false); // To synchronize print
//private static String threadID(){return(Thread.currentThread().getName());}

  private Log(){}

  public static void v(String tag,String msg) { println(VERBOSE,tag,msg,null); }
  public static void v(String tag,String msg,Throwable e) { println(VERBOSE,tag,msg,e); }

  public static void d(String tag,String msg) { println(DEBUG,tag,msg,null); }
  public static void d(String tag,String msg,Throwable tr) { println(DEBUG,tag,msg,tr); }

  public static void i(String tag,String msg) { println(INFO,tag,msg,null); }
  public static void i(String tag,String msg,Throwable tr) { println(INFO,tag,msg,tr); }

  public static void w(String tag,String msg) { println(WARN,tag,msg,null); }
  public static void w(String tag,String msg,Throwable tr) { println(WARN,tag,msg,tr); }

  public static void e(String tag,String msg) { println(ERROR,tag,msg,null); }
  public static void e(String tag,String msg,Throwable tr) { println(ERROR,tag,msg,tr); }

  public static void NOT_IMPLEMENTED(String tag,String msg) { println(ERROR,tag,msg,null); }
  
  public static void ASSERT(boolean test,String msg)
  { if(!test)
    { //synchronized(lock)
      { try { throw new RuntimeException("ASSERT("+msg+") -- FAILED"); }
        catch(Exception e) { e.printStackTrace(); }
      }
      //ERROR("ASSERTION FAILED",msg,null);
    }
  }

  public static void println(String msg) { System.out.println(msg); }

  private static void println(String level,String tag,String msg,Throwable e)
  { println(level+":"+tag+": "+msg);
	if(e!=null) e.printStackTrace();
  }
}
